package val.to.common;

import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class SimpleTaskCanceler implements ITaskCanceler{
	private boolean mCancled;
	private ReadWriteLock mLock = new ReentrantReadWriteLock();
	
	@Override
	public boolean isCanceled() {
		boolean c;
		mLock.readLock().lock();
		c = mCancled;
		mLock.readLock().unlock();
		
		return c;
	}
	
	@Override
	public void cancel() {
		mLock.writeLock().lock();
		mCancled = true;
		mLock.writeLock().unlock();
	}
}
